
var replyid = -1;
var replytitle = "";



function RemoveSelectedLetter()
{
	var selectids = "";
	var letters = $("#letterzone > input[type='checkbox']");
	
	for( i = 0; i < letters.length; i++ )
		if( letters[i].checked == true )
			$(letters[i]).parents().filter(".mail_item").remove();

}


function SelectAllLetters( this_ )
{
	if( this_.checked == true )
		$("#letterzone > input[type='checkbox']").attr( "checked", "true");
	else
		$("#letterzone > input[type='checkbox']").removeAttr( "checked");
	
}


function GetSelectedLetter()
{
	var selectids = "";
	var letters = $("#letterzone > input[type='checkbox']");
	
	for( i = 0; i < letters.length; i++ )
		if( letters[i].checked == true )
			selectids += letters[i].value + ",";

	return selectids;
}

function send_del_letter_request()
{
	MessageBox( "确定要删除吗?","删除确认",
			{
				yes: function(){
					  var params = "ids=" + GetSelectedLetter() + "&fromSender=1" ;
					  $.ajax(
				    	{
				                type: 'post',
				                url: edp_domain_url + 'ajax_del_letter/?tiny=1',
				                data: params,
								timeout: 5000,
								global:false,
					          
								error: function(XMLHttpRequest, textStatus, errorThrown)
								{
				    				SimpleMessage( '发送请求失败，稍后再试...', 2000 );
								},
				                success: function( data, textStatus )
				                {
									SimpleMessage( data, 500);
									RemoveSelectedLetter();
				                }
				         });}
			}
	);
	
}



function close_content( id_ )
{
	var item_content= 'item_content_'+id_;
	$("#"+item_content).hide();	
}

function show_content1( this_, id_ )
{
	var params = "id=" + id_;
	//replyid = sender_id_;
	//replytitle = "RE:" + $(this_).text().trim();			
	//$("#replyto").val( $(this_).nextAll(".author").text() );
	
	var item_content= 'item_content_'+id_ ;

	if( $("#"+item_content).is(':visible') ){
	
 		$("#"+item_content).hide();	
	}
	else{
		
		$.ajax({
	                type: 'post',
	                url: edp_domain_url + 'ajax_show_out_letter/?tiny=1',
	                data: params,
					timeout: 5000,
					global:false,
		          
					error: function(XMLHttpRequest, textStatus, errorThrown)
					{
			    		$.blockUI(
	    						{
	    							message: '发送请求失败，稍后再试...',
	    							css: { padding:'35px',color:'#CC0000'}
	    						});
	    				setTimeout($.unblockUI, 2000); 
					},
	                success: function( data, textStatus )
	                {
	            	                 		                 		            		
	                 	$("#"+item_content+">div[class='content_1']").html(data);		                 		                 			                 		
	                 	$("#"+item_content).show();		                	
	                }
			    });
		}	         
	
}


function del_item(id_, this_)
{
	MessageBox( "确定要删除吗?","删除确认",
			{
				yes: function(){
					  var params = "ids=" + id_+ "&fromSender=1";
					  $.ajax(
					   	{
					               type: 'post',
					               url: edp_domain_url + 'ajax_del_letter/?tiny=1',
					               data: params,
								timeout: 5000,
								global:false,
					          
								error: function(XMLHttpRequest, textStatus, errorThrown)
								{
					   		
					   				$.blockUI(
					   						{
					   							message: '发送请求失败，稍后再试...',
					   							css: { padding:'35px',color:'#CC0000'}
					   						});
					   				setTimeout($.unblockUI, 2000); 
					   				
								},
					               success: function( data, textStatus )
					               {
									
										SimpleMessage( data, 500 );
										
										$(this_).parents().filter(".mail_item").remove();
									
					               }
					        });
						}
			}
	);
      
	
}
